﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GraphCompiler.Core.SyntaxRepresentation;

namespace GraphCompiler.Core.Parsing
{
    public class ArrowParser : ParserBase<ArrowNode>
    {
        public override ArrowNode ParseTypedNode(TokenCollection tokens)
        {
            _tokens = tokens;

            var fromNameToken = ReadToken();
            ConsumeToken("->");
            var toNameToken = ReadToken();

            return new ArrowNode(fromNameToken.String, toNameToken.String);
        }

        public override bool IsApplicable(TokenCollection tokens)
        {
            if (tokens.Count() < 2)
                return false;

            return tokens.ElementAt(1).Equals(new Token("->"));
        }
    }
}